<template>
	<view class="orderAll">
		<!-- <view class="toper flex-row">
			<image src="../../static/icon/timer.png"></image>
			<view>
				<text>23</text>
				小时
				<text>26</text>
				分
				<text>12</text>
				秒后将自动关闭
			</view>
		</view> -->
		<view class="content">
			<view class="listBox"  v-if="List.length" v-for="(item,index) in List" :key='index'>
				<view class="list" @click="goDetail(item.id)">
					<view class="title">{{item.name}}</view>
					<view class="tagList flex-row">
						<view v-for="(i,index) in getlaber(item.keywords) " :key="index+5">{{i}}</view>
						
					</view>
					<!-- <view class="classList">
						<view>成果价值评估需求</view>
						<view>寻求销售渠道合作</view>
						<view>寻求销售渠道合作</view>
						<view>寻求法律维权服务</view>
					</view> -->
					<view class="desc text-ellipsis3">
						{{item.introduce}}
					</view>
				</view>
				<view class="priceBox flex-row flex-between">
					<view></view>
					<view class="flex-row">
						<view class="style">合作方式:买断</view>
						<view class="price">
							成交价格:
							<text >￥{{item.price}}</text>
						</view>
					</view>
				</view>
				<view class="statusBox flex-row flex-between">
					<!-- {{item.status==1?'待签约':item.status==2?'待支付':item.status==3?'卖家确认':item.status==4?'待过户':item.status==5?'买家待确认':item.status==6?'已完成':item.status==7?'已退款':item.status==8?'已取消'}} -->
					<view v-if="item.status==1" class="statusbox" >
						<view class="status">  </view>
						<view class="flex-row btnGroup">
							<view>待审核</view>
							<!-- <view class="op">立即签约</view> -->
						</view>
					</view>
					<view v-if="item.status==2" class="statusbox">
						<view class="status"> </view>
						<view class="flex-row btnGroup">
							<view class="op" style="margin-right: 20upx;" v-if="item.shelvesStatus==true" @click="refresh(item.id)">刷新</view>
							<view v-if="item.shelvesStatus==true" @click="showDialog('xiajia',item.id)">下架</view>
							<view v-if="item.shelvesStatus==false" @click="showDialog('shangjia',item.id)">上架</view>
							
							<view class="op">审核通过</view>
						</view>
					</view>
					<view v-if="item.status==3" class="statusbox">
						<view class="status"> </view>
						<view class="flex-row btnGroup">
							<view v-if="item.status == 3" @click="showDialog('edit',item.id)">修改</view>
							<view class="op">审核拒绝</view>
						</view>
					</view>
				</view>
			</view>
			
			<view class="textCenter paddingtb20 font30" v-if="List.length==''">暂无数据</view>
			<uni-popup ref="uniPop" type="dialog">
				<uni-popup-del :type="type" :opreate="opreate" :title="title" :content="content" :before-close="true" @confirm="dialogConfirm"
				 @close="dialogClose"></uni-popup-del>
			</uni-popup>
			
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				currentPage: 1,
				size: 10,
				type:'',
				List:[],
				opreate: "",
				shelvesStatus:'',
				title:'',
				content:''
			}
		},
		onLoad(option) {
			
			this.getOrderList()
		},
		
		methods:{
			//获取买订单列表
			getOrderList() {
				this.$http.get('/demand/getMyDemandList', {
					size: this.size,
					current: this.currentPage
				}).then(res => {
					if (res.code == '0') {
						this.List = res.data.records;
					}
				})
			},
			//刷新
			
			refresh(id){
				
				this.$http.get('/demand/refreshDemand', {
					demandId: id,
					
				}).then(res => {
					if (res.code == '0') {
						uni.showToast({
							title:res.msg,
							icon:'success',
							duration:1000,
						})
						// this.getOrderList()
					}
				})
			},
			
			goDetail(id){
				uni.navigateTo({
					url: '/pages/detail/index?id=' + id+'&need='+true
				})
			},
			getlaber(item) {
				return item.split(',')
			},
			//唤醒弹窗
			showDialog(opreate,id) {
				this.patentId = id
				if (opreate == '刷新') {
					// this.title = '警告';
					// this.content = "您正在进行专利删除操作 请谨慎！";
					this.opreate = 'refresh'
					
				} else if (opreate == 'shangjia') {
					this.title = '上架';
					this.content = "您正在进行上架操作";
					this.opreate = 'shangjia'
				} else if (opreate == 'xiajia') {
					this.title = '下架';
					this.content = "您正在进行下架操作";
					this.opreate = 'xiajia'
				} else if (opreate == 'edit') {
					this.title = '修改';
					this.content = "是否确认修改内容？";
					this.opreate = 'edit'
					uni.navigateTo({
						url:'../detail/fabu?type=2&id='+id
					})
				}
			
				this.$refs.uniPop.open()
			},
			// 上下架
			getshelfUpDown(flag) {
				var that = this;
				that.$http.get('/demand/shelfUpDown', {
					demandId: this.patentId,
					shelvesStatus: flag
				}).then(res => {
					if (res.code == '0') {
						this.myList = res.data.records;
						setTimeout(function(){
							uni.showToast({
								title:res.msg,
								icon:'success',
								duration:1000,
							})
						},1000)
						this.getOrderList()
					
						
					}
				})
			},
			/**
			 * 对话框点击确认按钮
			 */
			dialogConfirm(oprate, done) {
			
				// 需要执行 done 才能关闭对话框
				if (oprate == 'del') {
					console.log('点击删除的确认');
				} else if (oprate == 'shangjia') {
					console.log('点击上架的确认');
					this.getshelfUpDown(true)
					
				} else if (oprate == 'edit') {
					console.log('点击修改的确认');
				} else if (oprate == 'xiajia') {
					console.log('点击下架的确认');
					this.getshelfUpDown(false)
					
				}
				done()
			},
			/**
			 * 对话框取消按钮
			 */
			dialogClose(done) {
				this.msgType = 'info'
				this.message = '点击了对话框的取消按钮'
				// 需要执行 done 才能关闭对话框
				done()
			},
		},
		onNavigationBarButtonTap() {
			uni.navigateTo({
				url: '/pages/detail/fabu?type=2'
			});
		}
	}
</script>

<style scoped lang="scss">
.orderAll {
	.toper {
		padding: 25upx 20upx;
		font-size: 26upx;
		color: #22222a;
		background: rgba(253, 88, 10, 0.1);
		// justify-content: space-between;
		align-items: center;
		margin-bottom: 20upx;
		text {
			color: #39d214;
		}
		> image {
			width: 26upx;
			height: 26upx;
			margin-right: 12upx;
		}
	}
	.content {
		.listBox {
			background: #fff;
			padding: 0 30upx 40upx;
			margin-bottom: 20upx;
			.priceBox{
				align-items: center;
				padding: 34upx 0 48upx;
				.style{
					font-size: 30upx;
					color: #66666A;
				}
				.price{
					font-size: 30upx;
					color: #22222A;
					padding-left: 60upx;
					text{
						font-size:36upx;
						color: #FE590B;
					}
					
				}
			}
			.statusBox{
				.statusbox{
					width: 100%;
					display: flex;
					justify-content: space-between;
				}
				.status{
					font-size: 32upx;
					color: #FE590B;
				}
				.btnGroup{
					>view{
						width:142upx;
						height:50upx;
						border:1px solid rgba(154,154,154,1);
						border-radius:8upx;
						color: #9A9A9A;
						font-size: 29upx;
						text-align: center;
						line-height: 50upx;
						&.op{
							color: #FE590B;
							border:1px solid rgba(253,88,10,1);
							margin-left: 20upx;
						}
					}
				}
			}
			.list {
				padding: 30upx 0;
				border-bottom: 1upx solid rgba(238, 238, 238, 1);
				// &:last-child {
				// 	border-bottom: none;
				// }
				.title {
					font-size: 32upx;
					color: #22222a;
					font-weight: bold;
				}
				.tagList {
					padding-top: 23upx;
					padding-bottom: 23upx;
					> view {
						font-size: 22upx;
						color: #fd580a;
						border: 1upx solid #fd580a;
						padding: 5upx 10upx;
						margin-right: 16upx;
						border-radius: 8upx;
					}
				}
				.classList {
					color: #38d214;
					font-size: 26upx;
					// flex-wrap: wrap;
					> view {
						display: inline-flex;
						background: url(../../static/icon/green.png) no-repeat left 13upx;
						background-size: 8upx 8upx;
						padding-left: 20upx;
						margin-right: 37upx;
						padding-bottom: 20upx;
						&:first-child {
							margin-left: 0;
						}
					}
				}
				.desc {
					color: #666666;
					font-size: 28upx;
				}
			}
		}
	}
}
</style>
